// Author: InfiniteStarlight
#include<bits/stdc++.h>
using namespace std;
#define sz(v) (int)((v).size())
#define ALL(v) (v).begin(),(v).end()
#define rALL(v) (v).rbegin(),(v).rend()
#define srt(v) sort(ALL(v))
#define rsrt(v) sort(rALL(v))
#define lb(v,x) (int)(lower_bound(ALL(v),x)-(v).begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-(v).begin())
#define uni(v) (v).resize(unique(ALL(v))-(v).begin())
#define rev(v) reverse(ALL(v))
#define mp make_pair
#define pb emplace_back
#define inf 0x3f3f3f3f
using pii=pair<int,int>;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using i128=__int128_t;
using u128=__uint128_t;
int n,m,L,V;
int d[100100],v[100100],a[100100];
int p[100100];
int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--)
	{
		cin>>n>>m>>L>>V;
		for(int i=1;i<=n;i++)
			cin>>d[i]>>v[i]>>a[i];
		vector<pii> vec;
		for(int i=1;i<=m;i++)
			cin>>p[i];
		for(int i=1;i<=n;i++)
			if(a[i]==0)
			{
				if(v[i]<=V) continue;
				int l=1,r=m+1;
				while(l!=r)
				{
					int mid=(l+r)/2;
					if(p[mid]<d[i])
						l=mid+1;
					else
						r=mid;
				}
				if(l<=m) vec.pb(l,m);
			}
			else if(a[i]>0)
			{
				ll pos=(v[i]>V)?d[i]:((1ll*V*V-1ll*v[i]*v[i])/(a[i]*2)+1+d[i]);
				pos=min(pos,L+1ll);
				int l=1,r=m+1;
				while(l!=r)
				{
					int mid=(l+r)/2;
					if(p[mid]<pos)
						l=mid+1;
					else
						r=mid;
				}
				if(l<=m) vec.pb(l,m);
			}
			else
			{
				if(v[i]<=V) continue;
				int l=1,r=m+1;
				while(l!=r)
				{
					int mid=(l+r)/2;
					if(p[mid]<d[i])
						l=mid+1;
					else
						r=mid;
				}
				int st=l;
				ll pos=(1ll*v[i]*v[i]-1ll*V*V-1)/(a[i]*(-2))+d[i];
				l=0,r=m;
				while(l!=r)
				{
					int mid=(l+r+1)/2;
					if(p[mid]>pos)
						r=mid-1;
					else
						l=mid;
				}
				int nd=l;
				if(st<=nd)
					vec.pb(st,nd);
			}
		cout<<sz(vec)<<' ';
		int lst=0;
		sort(ALL(vec),[&](const auto &A,const auto &B){return A.second<B.second;});
		int ans=0;
		for(auto pr:vec)
			if(lst<pr.first)
			{
				ans++;
				lst=pr.second;
			}
		cout<<m-ans<<'\n';
	}
	return 0;
}